﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:FirstFloor.ModernUI.Windows.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/Converters.xaml" />
    </ResourceDictionary.MergedDictionaries>
    
    <Style TargetType="controls:ModernButton">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Foreground" Value="{DynamicResource ModernButtonText}" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:ModernButton">
                    <Grid x:Name="grid" Background="Transparent" Margin="{TemplateBinding Padding}" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Grid Width="18" Height="18">
                            <Ellipse x:Name="ellipse"
                                     Stroke="{DynamicResource ModernButtonBorder}"
                                     StrokeThickness="1"
                                     VerticalAlignment="Stretch" />
                            <Path x:Name="icon"
                                  Data="{TemplateBinding IconData}" 
                                  Width="{TemplateBinding IconWidth}"
                                  Height="{TemplateBinding IconHeight}"
                                  Fill="{TemplateBinding Foreground}"
                                  Stretch="Uniform" HorizontalAlignment="Center"
                                  VerticalAlignment="Center"/>
                        </Grid>
                        <Grid Grid.Column="1" >
                            <TextBlock DataContext="{TemplateBinding Content}"
                                       Text="{Binding Converter={StaticResource ToLowerConverter}}"
                                       TextTrimming="CharacterEllipsis"
                                       Foreground="{TemplateBinding Foreground}"
                                       Margin="4,-1,0,0"
                                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource ModernButtonTextHover}" />
                            <Setter TargetName="ellipse" Property="Stroke" Value="{DynamicResource ModernButtonBorderHover}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource ModernButtonTextPressed}" />
                            <Setter TargetName="ellipse" Property="Stroke" Value="{DynamicResource ModernButtonBorderPressed}" />
                            <Setter TargetName="ellipse" Property="Fill" Value="{DynamicResource ModernButtonIconBackgroundPressed}" />
                            <Setter TargetName="icon" Property="Fill" Value="{DynamicResource ModernButtonIconForegroundPressed}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource ModernButtonTextDisabled}" />
                            <Setter TargetName="ellipse" Property="Stroke" Value="{DynamicResource ModernButtonBorderDisabled}" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="true">
                            <Setter TargetName="ellipse" Property="Stroke" Value="{DynamicResource Accent}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>